package com.framework.modules.sys.ueditor;

import com.baidu.ueditor.ActionEnter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class UediterController {

    //ueditoer配置代替demo中的controller.jsp,返回ueditor的配置
    @RequestMapping("/ueditorConfig")
    public void config(HttpServletRequest request , HttpServletResponse response)  {
        try {
            response.setContentType( "application/json");
            response.setCharacterEncoding( "utf-8" );
            String action = request.getParameter("action");
            String rootPath=this.getClass().getClassLoader().getResource("").getPath();
            //如果是初始化
            String exec = new ActionEnter(request, rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }




    }
}
